package com.yuanqiworld.vw.domain;

import org.apache.commons.io.IOUtils;
import org.springframework.roo.addon.dod.RooDataOnDemand;

import java.io.IOException;
import java.util.Collection;

@RooDataOnDemand(entity = UnityModel.class)
public class UnityModelDataOnDemand {
    // 初始化数据库：有多个版本的模型.
    public void initMultiVersion() throws IOException {
        String json = IOUtils.toString(UnityModelDataOnDemand.class.getClassLoader().getResourceAsStream("UnityModel-test.json"));
        Collection<UnityModel> unityModels = UnityModel.fromJsonArrayToUnityModels(json);
        for (UnityModel unityModel : unityModels) {
            unityModel.persist();
        }
    }
}
